package com.wuren.faceSwiping.drafts.controller;

import com.wuren.faceSwiping.drafts.entity.AppDrafts;
import com.wuren.faceSwiping.drafts.service.DraftsService;
import com.wuren.faceSwiping.helper.vo.ResponseBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/drafts")
@CrossOrigin("*")
public class DraftsController {
    @Autowired
    private DraftsService draftsService;
    @PostMapping("/addDrafts")
    public ResponseBean addDrafts(AppDrafts appDrafts){
        return new ResponseBean(200,0,draftsService.saveOrUpdate(appDrafts));
    }
    @PostMapping("/findDrafts")
    public ResponseBean findDrafts(int id , int salesmanId){
        return new ResponseBean(200,draftsService.findDrafts(id,salesmanId).size(),draftsService.findDrafts(id,salesmanId));
    }
    @PostMapping("/deleteDrafts")
    public ResponseBean deleteDrafts(int id){
        return new ResponseBean(200,0,draftsService.deleteDrafts(id));
    }
}
